<?php get_header(); ?>

	<main id="main" class="page-eventos" role="main">
		<!-- section -->
		<section id="content">
			
			<h1><?php the_title(); ?></h1>
			
			<?php
			$count = 0;
			$args = array(
				'post_type'              => 'evento',
				'pagination'             => true,
				'paged'                  => (get_query_var('paged')) ? get_query_var('paged') : 1,
				'posts_per_page'         => '6'
			);
			if($_GET["data"]){
				$data = explode("-", $_GET["data"]);
				$args['year'] = $data[0];
				$args['monthnum'] = $data[1];
				$args['day'] = $data[2];
			}

			$wp_query = new WP_Query($args);

			if ($wp_query->have_posts()){
				while ($wp_query->have_posts()) : $wp_query->the_post();
				?>
					<article id="post-<?php the_ID(); ?>" <?php post_class($count%2 == 0 ? 'clr' : ''); ?>>
						<?php the_post_thumbnail('evento-lista'); ?>
						<h2 class="t2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
						<p><a href="<?php the_permalink(); ?>"><?php echo limitar(strip_tags(get_the_content()), 200); ?></a></p>
						<br class="clear">
					</article>
					<!-- /article -->
				<?php $count++;
				endwhile;
				html5wp_pagination($wp_query->max_num_pages);
			}else{
			?>
				<h2>Não foram encontrados eventos</h2>
			<?php
			}
			wp_reset_postdata();
			?>
		
		</section>
		<!-- /section -->
		<?php get_sidebar(); ?>
	</main>
	<script>
		$(document).ready(function() {
			js.eventos();
		});
	</script>
<?php get_footer(); ?>
